using System.Collections.Generic;

namespace com.bodurov.SilverlightControls.XmlCodeEditor.Extensions
{
    public static class LinkedListOfT_Ext
    {
        public static T GetByIndex<T>(this LinkedList<T> list, int index)
        {
            if(index < 0) return default(T);

            var i = 0;
            var current = list.First;
            while(current != null)
            {
                if(i == index)
                {
                    return current.Value;
                }
                current = current.Next;
                i++;
            }
            return default(T);
        }
    }
}